package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table (name= "ordenesCompra")
public class OrdenCompraEntity implements Serializable{

	@Transient
	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue
	private Integer id;
	@OneToMany (cascade = CascadeType.ALL)
	@JoinColumn (name= "idOrdenCompra")
	private List<ItemOrdenCompraEntity> itemsOrden = new ArrayList<ItemOrdenCompraEntity>();
	
	
	public OrdenCompraEntity() {
	}

	
	
	public Integer getIdOrdenCompra() {
		return id;
	}
	public void setIdOrdenCompra(Integer idOrdenCompra) {
		this.id = idOrdenCompra;
	}
	public List<ItemOrdenCompraEntity> getItemOrdenCompra() {
		return itemsOrden;
	}
	public void setItemOrdenCompra(List<ItemOrdenCompraEntity> itemsOrden) {
		this.itemsOrden = itemsOrden;
	}



	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((itemsOrden == null) ? 0 : itemsOrden.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrdenCompraEntity other = (OrdenCompraEntity) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (itemsOrden == null) {
			if (other.itemsOrden != null)
				return false;
		} else if (!itemsOrden.equals(other.itemsOrden))
			return false;
		return true;
	}
	
	
}
